<extend name="Layout/ins_page" />
<block name="content">
	{:W('PageHeader/simple',array('name'=>'修改邮件分类','search'=>'N'))}
	<form method='post' id="form_data" name="form_data"  class="well form-horizontal">
		<input type="hidden" name="id" id="id" value="{$vo.id}">
		<input type="hidden" name="opmode" id="opmode" value="edit">
		<div class="form-group">
			<label class="col-sm-2 control-label" for="is_del">状态：</label>
			<div class="col-sm-10">
				<select  id="is_del" name="is_del" class="form-control col-10">
					<option value="0">启用</option>
					<option value="1">禁用</option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="sender_check">邮件到达时：</label>
			<div class="col-sm-10 form-inline">
				<label class="inline pull-left col-3">
					<input class="ace" type="checkbox" name="sender_check" id="sender_check" value="1"/>
					<span class="lbl"></span></label>
				<label class="control-label" for="sender_check">如果发件人 </label>
				<select class="form-control col-10" type="select-one" id="sender_option" name="sender_option"  >
					<option selected="selected" value="1">包含</option>
					<option value="0">不包含</option>
				</select>
				<input class="form-control col-20" type="text"  name="sender_key"  id="sender_key">
				<span class="help-inline">例如：abc@abc.com</span>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="domain_check">邮件到达时：</label>
			<div class="col-sm-10 form-inline">
				<label class="inline pull-left col-3">
					<input class="ace" type="checkbox" name="domain_check" id="domain_check" value="1"/>
					<span class="lbl"></span></label>
				<label class="control-label" for="domain_check">如果发件域 </label>
				<select class="form-control col-10" type="select-one" id="domain_option" name="domain_option"  >
					<option selected="selected" value="1">包含</option>
					<option value="0">不包含</option>
				</select>
				<input class="form-control col-20" type="text"  name="domain_key"  id="domain_key">
				<span class="help-inline">例如：@qq.com</span>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="recever_check">邮件到达时：</label>
			<div class="col-sm-10 form-inline">
				<label class="inline pull-left col-3">
					<input class="ace" type="checkbox" name="recever_check" id="recever_check" value="1"/>
					<span class="lbl"></span></label>
				<label class="control-label" for="recever_check">如果收件人 </label>
				<select class="form-control col-10" type="select-one" id="recever_option" name="recever_option"  >
					<option selected="selected" value="1">包含</option>
					<option value="0">不包含</option>
				</select>
				<input class="form-control col-20" type="text"  name="recever_key"  id="recever_key">
				<span class="help-inline">例如：abc@abc.com</span>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="title_check">邮件到达时：</label>
			<div class="col-sm-10 form-inline">
				<label class="inline pull-left col-3">
					<input class="ace" type="checkbox" name="title_check" id="title_check" value="1"/>
					<span class="lbl"></span></label>
				<label class="control-label" for="title_check">如果标题中 </label>
				<select class="form-control col-10" type="select-one" id="title_option" name="title_option"  >
					<option selected="selected" value="1">包含</option>
					<option value="0">不包含</option>
				</select>
				<input class="form-control col-20" type="text"  name="title_key"  id="title_key">
				<span class="help-inline">例如：abc@abc.com</span>
			</div>
		</div>
		<hr>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="title_check">满足以上条件：</label>
			<div class="col-sm-10">
				<select class="form-control col-20"  id="to" name="to" >
					<option>请选择</option>
					{:fill_option($mail_folder)}
				</select>
			</div>
		</div>

		<div class="action">
			<input class="btn btn-sm btn-primary" type="button" value="保存" onclick="save();">
			<input  class="btn btn-sm btn-default" type="button" value="取消" onclick="go_return_url();">
		</div>
	</form>
</block>
<block name="js">
	<script type="text/javascript">
		function save() {
			if ($(":checkbox:checked").length == 0) {
				ui_error("请至少选择一项");
				$("#sender_check").focus();
				return false;
			}

			if (($("#sender_check").prop("checked") == "checked") && ($("#sender_key").val() == "")) {
				ui_error("内容不能为空1");
				$("#sender_key").focus();
				return false;
			}

			if (($("#domain_check").prop("checked") == "checked") && ($("#domain_key").val() == "")) {
				ui_error("内容不能为空2");
				$("#domain_key").focus();
				return false;
			}

			if (($("#recever_check").prop("checked") == "checked") && ($("#recever_key").val() == "")) {
				ui_error("内容不能为空3");
				$("#recever_key").focus();
				return false;
			}

			if (($("#title_check").prop("checked") == "checked") && ($("#title_key").val() == "")) {
				ui_error("内容不能为空4");
				$("#title_key").focus();
				return false;
			}
			if ($("#to").val() == "") {
				ui_error("请选择文件夹");
				$("#to").focus();
				return false;
			}
			sendForm("form_data", "{:U('save')}");
		}


		$(document).ready(function() {

			$("div.combo input").focus(function() {
				$(this).parent().find("label").hide();
			});
			$("div.combo input").blur(function() {
				if ($(this).val().length == 0) {
					$(this).parent().find("label").show();
				}
			});
			set_val("sender_check", "{$vo.sender_check}");
			set_val("sender_option", "{$vo.sender_option}");
			set_val("sender_key", "{$vo.sender_key}");

			set_val("recever_check", "{$vo.recever_check}");
			set_val("recever_option", "{$vo.recever_option}");
			set_val("recever_key", "{$vo.recever_key}");

			set_val("domain_check", "{$vo.domain_check}");
			set_val("domain_option", "{$vo.domain_option}");
			set_val("domain_key", "{$vo.domain_key}");

			set_val("title_check", "{$vo.title_check}");
			set_val("title_option", "{$vo.title_option}");
			set_val("title_key", "{$vo.title_key}");
			set_val("is_del", "{$vo.is_del}");

			set_val("to", "{$vo.to}");
			$("div.combo input").each(function() {
				if ($(this).val().length > 1) {
					$(this).parent().find("label").hide();
				}
			})
		});
	</script>
</block>